/*
 *  Copyright 2012, Tera-soft Co., Ltd.  All right reserved.
 *
 *  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF TERA-SOFT CO.,
 *  LTD.  THE CONTENTS OF THIS FILE MAY NOT BE DISCLOSED TO THIRD
 *  PARTIES, COPIED OR DUPLICATED IN ANY FORM, IN WHOLE OR IN PART,
 *  WITHOUT THE PRIOR WRITTEN PERMISSION OF TERA-SOFT CO., LTD
 *
 */
package com.tera.util;

import java.io.IOException;
import java.util.Date;
import java.util.Random;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import oracle.sql.DATE;
/**
 * @author wy
 */
public class FormTokenTag extends TagSupport {

	/**
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public int doEndTag() throws JspException {
		String token = TokenUtils.createToken();
		StringBuffer sb = new StringBuffer();
		this.pageContext.getSession().setAttribute("formToken", token);
		sb.append("<input id=\"formToken\" name=\"formToken\" type=\"hidden\" value=\"" + token + "\"/>");

		JspWriter out = pageContext.getOut();

		try {
			out.print(sb.toString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return super.doEndTag();
	}


}
